package cn.wolfcode.controller;


import cn.wolfcode.domain.PageResult;
import cn.wolfcode.domain.Result;
import cn.wolfcode.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/emps")
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping
    public Result query(@RequestParam(defaultValue = "1") int page,
                        @RequestParam(defaultValue = "10") int pageSize,
                        String name, Integer gender, @DateTimeFormat(pattern = "yyyy-MM-dd") Date begin,
                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
        PageResult pageResult = empService.query(page, pageSize,name,gender,begin,end);
        return Result.success(pageResult);
    }
}
